<?php

use Faker\Factory as Faker;
use App\Models\OrderRecord;
use App\Repositories\OrderRecordRepository;

trait MakeOrderRecordTrait
{
    /**
     * Create fake instance of OrderRecord and save it in database
     *
     * @param array $orderRecordFields
     * @return OrderRecord
     */
    public function makeOrderRecord($orderRecordFields = [])
    {
        /** @var OrderRecordRepository $orderRecordRepo */
        $orderRecordRepo = App::make(OrderRecordRepository::class);
        $theme = $this->fakeOrderRecordData($orderRecordFields);
        return $orderRecordRepo->create($theme);
    }

    /**
     * Get fake instance of OrderRecord
     *
     * @param array $orderRecordFields
     * @return OrderRecord
     */
    public function fakeOrderRecord($orderRecordFields = [])
    {
        return new OrderRecord($this->fakeOrderRecordData($orderRecordFields));
    }

    /**
     * Get fake data of OrderRecord
     *
     * @param array $postFields
     * @return array
     */
    public function fakeOrderRecordData($orderRecordFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'created_at' => $fake->word,
            'updated_at' => $fake->word
        ], $orderRecordFields);
    }
}
